using Documenter
using GSICoreAnalysis

# Define the documentation build configuration
makedocs(
    sitename = "GSICoreAnalysis.jl",
    authors = "GSI Development Team",
    modules = [GSICoreAnalysis],
    format = Documenter.HTML(
        prettyurls = get(ENV, "CI", nothing) == "true",
        canonical = "https://gsi-team.github.io/GSICoreAnalysis.jl",
        assets = String[],
        sidebar_sitename = false,
        edit_link = "main",
        repolink = "https://github.com/GSI-Team/GSICoreAnalysis.jl"
    ),
    pages = [
        "Home" => "index.md",
        "Manual" => [
            "Installation" => "manual/installation.md",
            "Quick Start" => "manual/quickstart.md", 
            "Configuration" => "manual/configuration.md",
            "Basic Usage" => "manual/basic_usage.md",
            "Advanced Features" => "manual/advanced.md",
            "Performance Tips" => "manual/performance.md",
            "Examples" => "manual/examples.md"
        ],
        "Theory" => [
            "Mathematical Foundation" => "theory/mathematical_foundation.md",
            "Variational Methods" => "theory/variational_methods.md",
            "Cost Functions" => "theory/cost_functions.md",
            "Minimization Algorithms" => "theory/minimization.md",
            "Background Error Covariance" => "theory/background_error.md",
            "Hybrid Methods" => "theory/hybrid_methods.md",
            "Observation Operators" => "theory/observation_operators.md"
        ],
        "API Reference" => [
            "Core Types" => "api/types.md",
            "Control Vectors" => "api/control_vectors.md",
            "State Vectors" => "api/state_vectors.md", 
            "Cost Functions" => "api/cost_functions.md",
            "Minimization" => "api/minimization.md",
            "Utilities" => "api/utilities.md"
        ],
        "Developer Guide" => [
            "Contributing" => "developer/contributing.md",
            "Architecture" => "developer/architecture.md",
            "Testing" => "developer/testing.md",
            "Benchmarking" => "developer/benchmarking.md"
        ]
    ],
    repo = "https://github.com/GSI-Team/GSICoreAnalysis.jl/blob/{commit}{path}#{line}",
    checkdocs = :exports,
    linkcheck = true,
    strict = false,
    doctest = false  # Disable doctests for now during development
)

# Deploy documentation to GitHub Pages
deploydocs(
    repo = "github.com/GSI-Team/GSICoreAnalysis.jl.git",
    target = "build",
    branch = "gh-pages",
    devbranch = "main",
    versions = ["stable" => "v^", "v#.#", "dev" => "main"]
)